package com.lepu.app.fun.hospital;

import java.util.Timer;
import java.util.TimerTask;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.core.lib.application.BaseFragmentActivity;
import com.eyzhs.app.R;
import com.lepu.app.fun.chat.activity.OnlineActivity;

public class HospitalExpertStateActivity extends BaseFragmentActivity {

	private Timer mTimer = null;
	private int mTimeValue = 3;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.hospital_expert_state_activity);

		init();
	}

	@Override
	public void onDestroy() { 
		super.onDestroy();
	}

	/**
	 * 添加页面动画，需要重写这个方法，
	 */
	@Override
	public void onBackPressed() {
		finish();
	}


	/**
	 * 初始化方法
	 */
	private void init() {
		mTimer = new Timer();
		mTimer.schedule(new TimerTask() {

             @Override
             public void run() {
            	 mHandler.sendEmptyMessage(0);
             }
         }, 0, 1000);
		
		
	}
	
    @SuppressLint("HandlerLeak")
	Handler mHandler = new Handler(){
        public void handleMessage(Message msg){
            switch (msg.what){
                case 0:

                    if(mTimeValue <= 0)
                    {
                    	mTimer.cancel();
                    	
                    	Intent intent = new Intent(HospitalExpertStateActivity.this, HospitalAdviceReportActivity.class);
                    	startActivity(intent,true);
                    	
                    	
                    	mHandler.postDelayed(new Runnable() {

        					@Override
        					public void run() {
        						 finish();
        	                        
        	                        if(OnlineActivity.getInstance() != null){
        	                        	OnlineActivity.getInstance().finish();
        	                        }
        					}
        				}, 500);
                       
                        
                    }else{
                    	
                    	mTimeValue --;
                    
                    }
                    break;
                default:
                    break;
            }
        }
    };

}
